<html>
<head><meta charset="utf-8"><title>simplifying macro repros · t-compiler/help · Zulip Chat Archive</title></head>
<h2>Stream: <a href="https://rust-lang.github.io/zulip_archive/stream/182449-t-compiler/help/index.html">t-compiler/help</a></h2>
<h3>Topic: <a href="https://rust-lang.github.io/zulip_archive/stream/182449-t-compiler/help/topic/simplifying.20macro.20repros.html">simplifying macro repros</a></h3>

<hr>

<base href="https://rust-lang.zulipchat.com">

<head><link href="https://rust-lang.github.io/zulip_archive/style.css" rel="stylesheet"></head>

<a name="171259074"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/182449-t-compiler/help/topic/simplifying%20macro%20repros/near/171259074" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> davidtwco <a href="https://rust-lang.github.io/zulip_archive/stream/182449-t-compiler/help/topic/simplifying.20macro.20repros.html#171259074">(Jul 19 2019 at 13:55)</a>:</h4>
<p>I've managed to minimize <a href="https://github.com/rust-lang/rust/issues/61693" target="_blank" title="https://github.com/rust-lang/rust/issues/61693">#61693</a> to something pretty small, but depends on <code>syn</code>, <code>quote</code> and <code>proc_macro2</code> and I've not managed to strip those out yet. Does anyone have any experience with crafting compiler test cases from code like this?</p>



<a name="171260251"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/182449-t-compiler/help/topic/simplifying%20macro%20repros/near/171260251" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> davidtwco <a href="https://rust-lang.github.io/zulip_archive/stream/182449-t-compiler/help/topic/simplifying.20macro.20repros.html#171260251">(Jul 19 2019 at 14:09)</a>:</h4>
<p>My current progress w/ the repro is linked in <a href="https://github.com/rust-lang/rust/issues/61963#issuecomment-513242465" target="_blank" title="https://github.com/rust-lang/rust/issues/61963#issuecomment-513242465">this comment</a>.</p>



<a name="171274090"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/182449-t-compiler/help/topic/simplifying%20macro%20repros/near/171274090" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> lqd <a href="https://rust-lang.github.io/zulip_archive/stream/182449-t-compiler/help/topic/simplifying.20macro.20repros.html#171274090">(Jul 19 2019 at 16:59)</a>:</h4>
<p><span class="user-mention" data-user-id="116107">@davidtwco</span> haha</p>



<a name="171274104"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/182449-t-compiler/help/topic/simplifying%20macro%20repros/near/171274104" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> lqd <a href="https://rust-lang.github.io/zulip_archive/stream/182449-t-compiler/help/topic/simplifying.20macro.20repros.html#171274104">(Jul 19 2019 at 16:59)</a>:</h4>
<p>I tried removing sync/quote etc from the attribute crate</p>



<a name="171274210"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/182449-t-compiler/help/topic/simplifying%20macro%20repros/near/171274210" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> lqd <a href="https://rust-lang.github.io/zulip_archive/stream/182449-t-compiler/help/topic/simplifying.20macro.20repros.html#171274210">(Jul 19 2019 at 17:00)</a>:</h4>
<p><a href="https://gist.github.com/lqd/1d882a8e8c9d41f3318ad98d60f8a11a" target="_blank" title="https://gist.github.com/lqd/1d882a8e8c9d41f3318ad98d60f8a11a">this works</a> but note the super important space</p>



<a name="171274240"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/182449-t-compiler/help/topic/simplifying%20macro%20repros/near/171274240" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> lqd <a href="https://rust-lang.github.io/zulip_archive/stream/182449-t-compiler/help/topic/simplifying.20macro.20repros.html#171274240">(Jul 19 2019 at 17:00)</a>:</h4>
<div class="codehilite"><pre><span></span><span class="c1">// note: qux: Qux&lt;Qux&lt;Baz&gt; &gt;,</span>
<span class="c1">// the space              ^ here is important</span>
</pre></div>



<a name="171274246"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/182449-t-compiler/help/topic/simplifying%20macro%20repros/near/171274246" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> davidtwco <a href="https://rust-lang.github.io/zulip_archive/stream/182449-t-compiler/help/topic/simplifying.20macro.20repros.html#171274246">(Jul 19 2019 at 17:01)</a>:</h4>
<p>Oh, wow. I wouldn’t have thought of that.</p>



<a name="171274312"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/182449-t-compiler/help/topic/simplifying%20macro%20repros/near/171274312" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> lqd <a href="https://rust-lang.github.io/zulip_archive/stream/182449-t-compiler/help/topic/simplifying.20macro.20repros.html#171274312">(Jul 19 2019 at 17:01)</a>:</h4>
<p>without the space it builds, with it there's your <code>^^^^^^^^^^^^^ help: use </code>dyn<code>: </code>dyn #[dom_struct]`</p>



<a name="171274367"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/182449-t-compiler/help/topic/simplifying%20macro%20repros/near/171274367" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> davidtwco <a href="https://rust-lang.github.io/zulip_archive/stream/182449-t-compiler/help/topic/simplifying.20macro.20repros.html#171274367">(Jul 19 2019 at 17:02)</a>:</h4>
<p>That’s mad.</p>



<a name="171274400"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/182449-t-compiler/help/topic/simplifying%20macro%20repros/near/171274400" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> lqd <a href="https://rust-lang.github.io/zulip_archive/stream/182449-t-compiler/help/topic/simplifying.20macro.20repros.html#171274400">(Jul 19 2019 at 17:02)</a>:</h4>
<p>I haven't looked at the custom derive yet but I assume we can use the same strategy: output a static TokenStream</p>



<a name="171274411"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/182449-t-compiler/help/topic/simplifying%20macro%20repros/near/171274411" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> davidtwco <a href="https://rust-lang.github.io/zulip_archive/stream/182449-t-compiler/help/topic/simplifying.20macro.20repros.html#171274411">(Jul 19 2019 at 17:02)</a>:</h4>
<p>I’ve not looked much into what’s happening in the compiler yet, just focused on getting a test case that works.</p>



<a name="171274454"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/182449-t-compiler/help/topic/simplifying%20macro%20repros/near/171274454" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> davidtwco <a href="https://rust-lang.github.io/zulip_archive/stream/182449-t-compiler/help/topic/simplifying.20macro.20repros.html#171274454">(Jul 19 2019 at 17:03)</a>:</h4>
<p>Yeah, that’s probably a good idea. Way easier than what I had been trying.</p>



<a name="171274457"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/182449-t-compiler/help/topic/simplifying%20macro%20repros/near/171274457" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> davidtwco <a href="https://rust-lang.github.io/zulip_archive/stream/182449-t-compiler/help/topic/simplifying.20macro.20repros.html#171274457">(Jul 19 2019 at 17:03)</a>:</h4>
<p>Thanks!</p>



<a name="171274460"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/182449-t-compiler/help/topic/simplifying%20macro%20repros/near/171274460" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> lqd <a href="https://rust-lang.github.io/zulip_archive/stream/182449-t-compiler/help/topic/simplifying.20macro.20repros.html#171274460">(Jul 19 2019 at 17:03)</a>:</h4>
<p>this is what I tried in the first crate but couldn't get it to work, so I built both tokenstreams with proc_macro::quote and syn::quote</p>



<a name="171274473"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/182449-t-compiler/help/topic/simplifying%20macro%20repros/near/171274473" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> lqd <a href="https://rust-lang.github.io/zulip_archive/stream/182449-t-compiler/help/topic/simplifying.20macro.20repros.html#171274473">(Jul 19 2019 at 17:03)</a>:</h4>
<p>and asserted they were equal, and they were not</p>



<a name="171274493"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/182449-t-compiler/help/topic/simplifying%20macro%20repros/near/171274493" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> lqd <a href="https://rust-lang.github.io/zulip_archive/stream/182449-t-compiler/help/topic/simplifying.20macro.20repros.html#171274493">(Jul 19 2019 at 17:03)</a>:</h4>
<p>so this is where the space comes from</p>



<a name="171274524"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/182449-t-compiler/help/topic/simplifying%20macro%20repros/near/171274524" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> davidtwco <a href="https://rust-lang.github.io/zulip_archive/stream/182449-t-compiler/help/topic/simplifying.20macro.20repros.html#171274524">(Jul 19 2019 at 17:04)</a>:</h4>
<p>Could probably look at <code>-Z unpretty</code> output.</p>



<a name="171274574"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/182449-t-compiler/help/topic/simplifying%20macro%20repros/near/171274574" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> lqd <a href="https://rust-lang.github.io/zulip_archive/stream/182449-t-compiler/help/topic/simplifying.20macro.20repros.html#171274574">(Jul 19 2019 at 17:04)</a>:</h4>
<p>I tried to get the pretty=expanded but I wasn't to easily get the expanded proc macros token</p>



<a name="171274604"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/182449-t-compiler/help/topic/simplifying%20macro%20repros/near/171274604" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> lqd <a href="https://rust-lang.github.io/zulip_archive/stream/182449-t-compiler/help/topic/simplifying.20macro.20repros.html#171274604">(Jul 19 2019 at 17:05)</a>:</h4>
<p>do you know if it works with proc macros or only macros ?</p>



<a name="171274643"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/182449-t-compiler/help/topic/simplifying%20macro%20repros/near/171274643" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> davidtwco <a href="https://rust-lang.github.io/zulip_archive/stream/182449-t-compiler/help/topic/simplifying.20macro.20repros.html#171274643">(Jul 19 2019 at 17:05)</a>:</h4>
<p>I’m not sure. I’ve not got all that much experience with either.</p>



<a name="171274785"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/182449-t-compiler/help/topic/simplifying%20macro%20repros/near/171274785" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> lqd <a href="https://rust-lang.github.io/zulip_archive/stream/182449-t-compiler/help/topic/simplifying.20macro.20repros.html#171274785">(Jul 19 2019 at 17:07)</a>:</h4>
<p>ah yes it does work</p>



<a name="171274852"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/182449-t-compiler/help/topic/simplifying%20macro%20repros/near/171274852" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> lqd <a href="https://rust-lang.github.io/zulip_archive/stream/182449-t-compiler/help/topic/simplifying.20macro.20repros.html#171274852">(Jul 19 2019 at 17:08)</a>:</h4>
<p>to get the errors shown on the attributes etc we might indeed need multiple crates tho</p>



<a name="171274871"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/182449-t-compiler/help/topic/simplifying%20macro%20repros/near/171274871" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> davidtwco <a href="https://rust-lang.github.io/zulip_archive/stream/182449-t-compiler/help/topic/simplifying.20macro.20repros.html#171274871">(Jul 19 2019 at 17:08)</a>:</h4>
<p>That’s fine, can do that in compiletest.</p>



<a name="171274877"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/182449-t-compiler/help/topic/simplifying%20macro%20repros/near/171274877" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> lqd <a href="https://rust-lang.github.io/zulip_archive/stream/182449-t-compiler/help/topic/simplifying.20macro.20repros.html#171274877">(Jul 19 2019 at 17:08)</a>:</h4>
<p>true (I was mostly responding to the comment about unpretty output)</p>



<a name="171274890"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/182449-t-compiler/help/topic/simplifying%20macro%20repros/near/171274890" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> lqd <a href="https://rust-lang.github.io/zulip_archive/stream/182449-t-compiler/help/topic/simplifying.20macro.20repros.html#171274890">(Jul 19 2019 at 17:08)</a>:</h4>
<p>I'll try to simplify the derive if you're not working on it ?</p>



<a name="171274935"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/182449-t-compiler/help/topic/simplifying%20macro%20repros/near/171274935" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> davidtwco <a href="https://rust-lang.github.io/zulip_archive/stream/182449-t-compiler/help/topic/simplifying.20macro.20repros.html#171274935">(Jul 19 2019 at 17:09)</a>:</h4>
<p>I’ve stepped away from the computer for a bit. Feel free to, I’d appreciate it.</p>



<a name="171274947"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/182449-t-compiler/help/topic/simplifying%20macro%20repros/near/171274947" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> lqd <a href="https://rust-lang.github.io/zulip_archive/stream/182449-t-compiler/help/topic/simplifying.20macro.20repros.html#171274947">(Jul 19 2019 at 17:09)</a>:</h4>
<p>sure</p>



<a name="171277024"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/182449-t-compiler/help/topic/simplifying%20macro%20repros/near/171277024" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> lqd <a href="https://rust-lang.github.io/zulip_archive/stream/182449-t-compiler/help/topic/simplifying.20macro.20repros.html#171277024">(Jul 19 2019 at 17:35)</a>:</h4>
<p>it's a bit tougher in the second case, it's related to the spans I think, they look weird with syn/quote</p>



<a name="171281213"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/182449-t-compiler/help/topic/simplifying%20macro%20repros/near/171281213" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> davidtwco <a href="https://rust-lang.github.io/zulip_archive/stream/182449-t-compiler/help/topic/simplifying.20macro.20repros.html#171281213">(Jul 19 2019 at 18:22)</a>:</h4>
<p>That’s unfortunate.</p>



<a name="171281218"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/182449-t-compiler/help/topic/simplifying%20macro%20repros/near/171281218" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> davidtwco <a href="https://rust-lang.github.io/zulip_archive/stream/182449-t-compiler/help/topic/simplifying.20macro.20repros.html#171281218">(Jul 19 2019 at 18:22)</a>:</h4>
<p>I was wondering if it was something like that.</p>



<a name="171282509"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/182449-t-compiler/help/topic/simplifying%20macro%20repros/near/171282509" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> lqd <a href="https://rust-lang.github.io/zulip_archive/stream/182449-t-compiler/help/topic/simplifying.20macro.20repros.html#171282509">(Jul 19 2019 at 18:36)</a>:</h4>
<p>it appears we can't really create/mutate spans</p>



<a name="171282524"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/182449-t-compiler/help/topic/simplifying%20macro%20repros/near/171282524" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> lqd <a href="https://rust-lang.github.io/zulip_archive/stream/182449-t-compiler/help/topic/simplifying.20macro.20repros.html#171282524">(Jul 19 2019 at 18:36)</a>:</h4>
<p>here they might be invalid, I'll show you the output I get</p>



<a name="171282541"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/182449-t-compiler/help/topic/simplifying%20macro%20repros/near/171282541" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> lqd <a href="https://rust-lang.github.io/zulip_archive/stream/182449-t-compiler/help/topic/simplifying.20macro.20repros.html#171282541">(Jul 19 2019 at 18:36)</a>:</h4>
<p>but I'm not familiar with these so I wouldn't know</p>



<a name="171282663"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/182449-t-compiler/help/topic/simplifying%20macro%20repros/near/171282663" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> lqd <a href="https://rust-lang.github.io/zulip_archive/stream/182449-t-compiler/help/topic/simplifying.20macro.20repros.html#171282663">(Jul 19 2019 at 18:37)</a>:</h4>
<p>the <a href="https://gist.github.com/lqd/91a22edae631f3e8c7083e4a7614aba9" target="_blank" title="https://gist.github.com/lqd/91a22edae631f3e8c7083e4a7614aba9">test</a> and the <a href="https://gist.github.com/lqd/a021cf9e6e6e528d789e46d3fd441bbb" target="_blank" title="https://gist.github.com/lqd/a021cf9e6e6e528d789e46d3fd441bbb">output</a></p>



<a name="171282763"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/182449-t-compiler/help/topic/simplifying%20macro%20repros/near/171282763" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> lqd <a href="https://rust-lang.github.io/zulip_archive/stream/182449-t-compiler/help/topic/simplifying.20macro.20repros.html#171282763">(Jul 19 2019 at 18:38)</a>:</h4>
<p>I'm not even sure the problem is related to them, but there's some <code>#0 bytes(0..0)</code> spans, which seem like an interesting difference</p>



<a name="171282901"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/182449-t-compiler/help/topic/simplifying%20macro%20repros/near/171282901" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> lqd <a href="https://rust-lang.github.io/zulip_archive/stream/182449-t-compiler/help/topic/simplifying.20macro.20repros.html#171282901">(Jul 19 2019 at 18:40)</a>:</h4>
<p>if I modify the way to create the items with syn, juste quote! statically, the error disappears as well</p>



<a name="171282921"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/182449-t-compiler/help/topic/simplifying%20macro%20repros/near/171282921" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> lqd <a href="https://rust-lang.github.io/zulip_archive/stream/182449-t-compiler/help/topic/simplifying.20macro.20repros.html#171282921">(Jul 19 2019 at 18:40)</a>:</h4>
<p>so I'm a bit stumped <span class="user-mention" data-user-id="116107">@davidtwco</span></p>



<a name="171282977"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/182449-t-compiler/help/topic/simplifying%20macro%20repros/near/171282977" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> davidtwco <a href="https://rust-lang.github.io/zulip_archive/stream/182449-t-compiler/help/topic/simplifying.20macro.20repros.html#171282977">(Jul 19 2019 at 18:41)</a>:</h4>
<p>Hmm...</p>



<a name="171283049"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/182449-t-compiler/help/topic/simplifying%20macro%20repros/near/171283049" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> davidtwco <a href="https://rust-lang.github.io/zulip_archive/stream/182449-t-compiler/help/topic/simplifying.20macro.20repros.html#171283049">(Jul 19 2019 at 18:42)</a>:</h4>
<p>Can you index into the input stream (using <code>.into_iter().nth(..)</code>) and then use that to get the spans?</p>



<a name="171283067"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/182449-t-compiler/help/topic/simplifying%20macro%20repros/near/171283067" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> davidtwco <a href="https://rust-lang.github.io/zulip_archive/stream/182449-t-compiler/help/topic/simplifying.20macro.20repros.html#171283067">(Jul 19 2019 at 18:42)</a>:</h4>
<p>Nevermind, I was mixing up which spans were which.</p>



<a name="171283087"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/182449-t-compiler/help/topic/simplifying%20macro%20repros/near/171283087" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> lqd <a href="https://rust-lang.github.io/zulip_archive/stream/182449-t-compiler/help/topic/simplifying.20macro.20repros.html#171283087">(Jul 19 2019 at 18:42)</a>:</h4>
<p>I'll try to see how the spans look in the quoted static input just in case</p>



<a name="171283216"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/182449-t-compiler/help/topic/simplifying%20macro%20repros/near/171283216" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> lqd <a href="https://rust-lang.github.io/zulip_archive/stream/182449-t-compiler/help/topic/simplifying.20macro.20repros.html#171283216">(Jul 19 2019 at 18:44)</a>:</h4>
<p>they are identical to what proc_macro generates then</p>



<a name="171283220"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/182449-t-compiler/help/topic/simplifying%20macro%20repros/near/171283220" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> lqd <a href="https://rust-lang.github.io/zulip_archive/stream/182449-t-compiler/help/topic/simplifying.20macro.20repros.html#171283220">(Jul 19 2019 at 18:44)</a>:</h4>
<p>and the error disappears</p>



<a name="171283301"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/182449-t-compiler/help/topic/simplifying%20macro%20repros/near/171283301" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> davidtwco <a href="https://rust-lang.github.io/zulip_archive/stream/182449-t-compiler/help/topic/simplifying.20macro.20repros.html#171283301">(Jul 19 2019 at 18:45)</a>:</h4>
<p>So, we think syn/quote is making spans <code>bytes(0..0)</code> and that's what's causing the issue?</p>



<a name="171283318"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/182449-t-compiler/help/topic/simplifying%20macro%20repros/near/171283318" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> davidtwco <a href="https://rust-lang.github.io/zulip_archive/stream/182449-t-compiler/help/topic/simplifying.20macro.20repros.html#171283318">(Jul 19 2019 at 18:45)</a>:</h4>
<p>Since that's the only difference?</p>



<a name="171283344"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/182449-t-compiler/help/topic/simplifying%20macro%20repros/near/171283344" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> lqd <a href="https://rust-lang.github.io/zulip_archive/stream/182449-t-compiler/help/topic/simplifying.20macro.20repros.html#171283344">(Jul 19 2019 at 18:45)</a>:</h4>
<p>it's a bit hard to tell honestly :)</p>



<a name="171283355"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/182449-t-compiler/help/topic/simplifying%20macro%20repros/near/171283355" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> lqd <a href="https://rust-lang.github.io/zulip_archive/stream/182449-t-compiler/help/topic/simplifying.20macro.20repros.html#171283355">(Jul 19 2019 at 18:46)</a>:</h4>
<p>it's the only difference I was able to see in the time I looked at it</p>



<a name="171283459"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/182449-t-compiler/help/topic/simplifying%20macro%20repros/near/171283459" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> lqd <a href="https://rust-lang.github.io/zulip_archive/stream/182449-t-compiler/help/topic/simplifying.20macro.20repros.html#171283459">(Jul 19 2019 at 18:46)</a>:</h4>
<p>I'll makesure again the output is identical</p>



<a name="171283467"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/182449-t-compiler/help/topic/simplifying%20macro%20repros/near/171283467" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> davidtwco <a href="https://rust-lang.github.io/zulip_archive/stream/182449-t-compiler/help/topic/simplifying.20macro.20repros.html#171283467">(Jul 19 2019 at 18:46)</a>:</h4>
<p>Thanks for taking a look, I'll see what I can dig up when I get back to a machine.</p>



<a name="171283865"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/182449-t-compiler/help/topic/simplifying%20macro%20repros/near/171283865" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> lqd <a href="https://rust-lang.github.io/zulip_archive/stream/182449-t-compiler/help/topic/simplifying.20macro.20repros.html#171283865">(Jul 19 2019 at 18:51)</a>:</h4>
<p>the expanded output is indeed identical</p>



<a name="171283992"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/182449-t-compiler/help/topic/simplifying%20macro%20repros/near/171283992" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> lqd <a href="https://rust-lang.github.io/zulip_archive/stream/182449-t-compiler/help/topic/simplifying.20macro.20repros.html#171283992">(Jul 19 2019 at 18:52)</a>:</h4>
<p>why isn't the bare trait giving a warning in the other case ......</p>



<a name="171284153"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/182449-t-compiler/help/topic/simplifying%20macro%20repros/near/171284153" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> lqd <a href="https://rust-lang.github.io/zulip_archive/stream/182449-t-compiler/help/topic/simplifying.20macro.20repros.html#171284153">(Jul 19 2019 at 18:54)</a>:</h4>
<p>I really gtg though, I'll update the derive test so that you can see what I'm talking about :)</p>



<a name="171284176"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/182449-t-compiler/help/topic/simplifying%20macro%20repros/near/171284176" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> davidtwco <a href="https://rust-lang.github.io/zulip_archive/stream/182449-t-compiler/help/topic/simplifying.20macro.20repros.html#171284176">(Jul 19 2019 at 18:54)</a>:</h4>
<p>Thanks, appreciate the help.</p>



<a name="171284197"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/182449-t-compiler/help/topic/simplifying%20macro%20repros/near/171284197" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> lqd <a href="https://rust-lang.github.io/zulip_archive/stream/182449-t-compiler/help/topic/simplifying.20macro.20repros.html#171284197">(Jul 19 2019 at 18:54)</a>:</h4>
<p><a href="https://gist.github.com/lqd/05d84be2fb83bd69b880999f254a1964" target="_blank" title="https://gist.github.com/lqd/05d84be2fb83bd69b880999f254a1964">updated here</a></p>



<a name="171284206"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/182449-t-compiler/help/topic/simplifying%20macro%20repros/near/171284206" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> lqd <a href="https://rust-lang.github.io/zulip_archive/stream/182449-t-compiler/help/topic/simplifying.20macro.20repros.html#171284206">(Jul 19 2019 at 18:54)</a>:</h4>
<p>no problem :)</p>



<a name="171284228"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/182449-t-compiler/help/topic/simplifying%20macro%20repros/near/171284228" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> lqd <a href="https://rust-lang.github.io/zulip_archive/stream/182449-t-compiler/help/topic/simplifying.20macro.20repros.html#171284228">(Jul 19 2019 at 18:55)</a>:</h4>
<p>a weird one for sure</p>



<a name="171284282"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/182449-t-compiler/help/topic/simplifying%20macro%20repros/near/171284282" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> lqd <a href="https://rust-lang.github.io/zulip_archive/stream/182449-t-compiler/help/topic/simplifying.20macro.20repros.html#171284282">(Jul 19 2019 at 18:55)</a>:</h4>
<p>and that weird space.... :)</p>



<a name="171286901"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/182449-t-compiler/help/topic/simplifying%20macro%20repros/near/171286901" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> davidtwco <a href="https://rust-lang.github.io/zulip_archive/stream/182449-t-compiler/help/topic/simplifying.20macro.20repros.html#171286901">(Jul 19 2019 at 19:32)</a>:</h4>
<p>I think the bug here is probably that there's a way to get spans that are <code>bytes(0..0)</code> at all - I can't figure out how I'd construct those.</p>



<a name="171287048"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/182449-t-compiler/help/topic/simplifying%20macro%20repros/near/171287048" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> davidtwco <a href="https://rust-lang.github.io/zulip_archive/stream/182449-t-compiler/help/topic/simplifying.20macro.20repros.html#171287048">(Jul 19 2019 at 19:34)</a>:</h4>
<p><span class="user-mention" data-user-id="123856">@Vadim Petrochenkov</span> I'm not familiar at all with how <code>proc-macro</code> crates are intended to work, it there supposed to be a way to get what are effectively dummy spans in a <code>#[proc_macro_derive]</code>?</p>



<a name="171287060"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/182449-t-compiler/help/topic/simplifying%20macro%20repros/near/171287060" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> lqd <a href="https://rust-lang.github.io/zulip_archive/stream/182449-t-compiler/help/topic/simplifying.20macro.20repros.html#171287060">(Jul 19 2019 at 19:34)</a>:</h4>
<p>I'm also looking into how the quote crate does it</p>



<a name="171287063"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/182449-t-compiler/help/topic/simplifying%20macro%20repros/near/171287063" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> davidtwco <a href="https://rust-lang.github.io/zulip_archive/stream/182449-t-compiler/help/topic/simplifying.20macro.20repros.html#171287063">(Jul 19 2019 at 19:34)</a>:</h4>
<p>I'm able to reproduce the results you were getting.</p>



<a name="171287081"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/182449-t-compiler/help/topic/simplifying%20macro%20repros/near/171287081" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> davidtwco <a href="https://rust-lang.github.io/zulip_archive/stream/182449-t-compiler/help/topic/simplifying.20macro.20repros.html#171287081">(Jul 19 2019 at 19:35)</a>:</h4>
<p>I've been having a look at <code>quote</code> and <code>syn</code> and nothing is jumping out to me from a few GitHub searches.</p>



<a name="171287227"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/182449-t-compiler/help/topic/simplifying%20macro%20repros/near/171287227" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> lqd <a href="https://rust-lang.github.io/zulip_archive/stream/182449-t-compiler/help/topic/simplifying.20macro.20repros.html#171287227">(Jul 19 2019 at 19:37)</a>:</h4>
<p>it seems like an unlucky collision of a bunch of different factors</p>



<a name="171287364"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/182449-t-compiler/help/topic/simplifying%20macro%20repros/near/171287364" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> davidtwco <a href="https://rust-lang.github.io/zulip_archive/stream/182449-t-compiler/help/topic/simplifying.20macro.20repros.html#171287364">(Jul 19 2019 at 19:38)</a>:</h4>
<p>Probably from a use of <code>Span::def_site()</code> or <code>Span::call_site()</code>?</p>



<a name="171287538"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/182449-t-compiler/help/topic/simplifying%20macro%20repros/near/171287538" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> lqd <a href="https://rust-lang.github.io/zulip_archive/stream/182449-t-compiler/help/topic/simplifying.20macro.20repros.html#171287538">(Jul 19 2019 at 19:41)</a>:</h4>
<p>yeah I don't see another way to create them :)</p>



<a name="171287608"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/182449-t-compiler/help/topic/simplifying%20macro%20repros/near/171287608" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> lqd <a href="https://rust-lang.github.io/zulip_archive/stream/182449-t-compiler/help/topic/simplifying.20macro.20repros.html#171287608">(Jul 19 2019 at 19:42)</a>:</h4>
<p>if that's the case then in this context rustc is giving the weird spans to quote/proc_macro2 ?</p>



<a name="171287646"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/182449-t-compiler/help/topic/simplifying%20macro%20repros/near/171287646" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> davidtwco <a href="https://rust-lang.github.io/zulip_archive/stream/182449-t-compiler/help/topic/simplifying.20macro.20repros.html#171287646">(Jul 19 2019 at 19:43)</a>:</h4>
<p>Maybe? I have no idea how to craft a test for that.</p>



<a name="171287741"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/182449-t-compiler/help/topic/simplifying%20macro%20repros/near/171287741" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> lqd <a href="https://rust-lang.github.io/zulip_archive/stream/182449-t-compiler/help/topic/simplifying.20macro.20repros.html#171287741">(Jul 19 2019 at 19:44)</a>:</h4>
<p>or if it's even the real root cause of the problem</p>



<a name="171287921"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/182449-t-compiler/help/topic/simplifying%20macro%20repros/near/171287921" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> davidtwco <a href="https://rust-lang.github.io/zulip_archive/stream/182449-t-compiler/help/topic/simplifying.20macro.20repros.html#171287921">(Jul 19 2019 at 19:47)</a>:</h4>
<p>I can get <code>Span</code> to have a <code>#0</code> by calling <code>.parent()</code> twice.</p>



<a name="171287965"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/182449-t-compiler/help/topic/simplifying%20macro%20repros/near/171287965" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> davidtwco <a href="https://rust-lang.github.io/zulip_archive/stream/182449-t-compiler/help/topic/simplifying.20macro.20repros.html#171287965">(Jul 19 2019 at 19:48)</a>:</h4>
<p>But it doesn't change the range.</p>



<a name="171287987"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/182449-t-compiler/help/topic/simplifying%20macro%20repros/near/171287987" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> davidtwco <a href="https://rust-lang.github.io/zulip_archive/stream/182449-t-compiler/help/topic/simplifying.20macro.20repros.html#171287987">(Jul 19 2019 at 19:48)</a>:</h4>
<p>(that is, the <code>def_span</code> and <code>call_site</code> spans)</p>



<a name="171288137"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/182449-t-compiler/help/topic/simplifying%20macro%20repros/near/171288137" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> davidtwco <a href="https://rust-lang.github.io/zulip_archive/stream/182449-t-compiler/help/topic/simplifying.20macro.20repros.html#171288137">(Jul 19 2019 at 19:50)</a>:</h4>
<p><code>Literal::subspan</code> might also be useful if we could get a big enough initial <code>Span</code>.</p>



<a name="171288152"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/182449-t-compiler/help/topic/simplifying%20macro%20repros/near/171288152" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> lqd <a href="https://rust-lang.github.io/zulip_archive/stream/182449-t-compiler/help/topic/simplifying.20macro.20repros.html#171288152">(Jul 19 2019 at 19:50)</a>:</h4>
<p>maybe there's a way to get the proc_macro bridge server/client to create the weird range span :/</p>



<a name="171288206"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/182449-t-compiler/help/topic/simplifying%20macro%20repros/near/171288206" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> davidtwco <a href="https://rust-lang.github.io/zulip_archive/stream/182449-t-compiler/help/topic/simplifying.20macro.20repros.html#171288206">(Jul 19 2019 at 19:51)</a>:</h4>
<p><span aria-label="shrug" class="emoji emoji-1f937" role="img" title="shrug">:shrug:</span></p>



<a name="171288308"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/182449-t-compiler/help/topic/simplifying%20macro%20repros/near/171288308" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> davidtwco <a href="https://rust-lang.github.io/zulip_archive/stream/182449-t-compiler/help/topic/simplifying.20macro.20repros.html#171288308">(Jul 19 2019 at 19:53)</a>:</h4>
<p>Next thing would be to step through with a debugger everywhere that <code>quote</code> or <code>syn</code> gets a <code>Span</code> and find out where it gets the dummy span?</p>



<a name="171288346"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/182449-t-compiler/help/topic/simplifying%20macro%20repros/near/171288346" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> lqd <a href="https://rust-lang.github.io/zulip_archive/stream/182449-t-compiler/help/topic/simplifying.20macro.20repros.html#171288346">(Jul 19 2019 at 19:53)</a>:</h4>
<p>yeah interesting thought, we're a bit in the dark still</p>



<a name="171288353"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/182449-t-compiler/help/topic/simplifying%20macro%20repros/near/171288353" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> davidtwco <a href="https://rust-lang.github.io/zulip_archive/stream/182449-t-compiler/help/topic/simplifying.20macro.20repros.html#171288353">(Jul 19 2019 at 19:53)</a>:</h4>
<p>That's assuming that it is some <code>set_span</code> call in those crates that do it and not some other function that manipulates tokens or token streams.</p>



<a name="171288430"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/182449-t-compiler/help/topic/simplifying%20macro%20repros/near/171288430" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> lqd <a href="https://rust-lang.github.io/zulip_archive/stream/182449-t-compiler/help/topic/simplifying.20macro.20repros.html#171288430">(Jul 19 2019 at 19:54)</a>:</h4>
<p>it might also be Span::call_site/def_site but from inside proc_macro2</p>



<a name="171288461"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/182449-t-compiler/help/topic/simplifying%20macro%20repros/near/171288461" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> davidtwco <a href="https://rust-lang.github.io/zulip_archive/stream/182449-t-compiler/help/topic/simplifying.20macro.20repros.html#171288461">(Jul 19 2019 at 19:55)</a>:</h4>
<p>Yeah.</p>



<a name="171290963"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/182449-t-compiler/help/topic/simplifying%20macro%20repros/near/171290963" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> lqd <a href="https://rust-lang.github.io/zulip_archive/stream/182449-t-compiler/help/topic/simplifying.20macro.20repros.html#171290963">(Jul 19 2019 at 20:29)</a>:</h4>
<p>the contents sure look like the syntax DUMMY_SP but for proc_macro::Span</p>



<a name="171292321"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/182449-t-compiler/help/topic/simplifying%20macro%20repros/near/171292321" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> lqd <a href="https://rust-lang.github.io/zulip_archive/stream/182449-t-compiler/help/topic/simplifying.20macro.20repros.html#171292321">(Jul 19 2019 at 20:49)</a>:</h4>
<p><span class="user-mention" data-user-id="116107">@davidtwco</span> <a href="https://github.com/rust-lang/rust/blob/9ebf47851a357faa4cd97f4b1dc7835f6376e639/src/libsyntax_ext/proc_macro_server.rs#L454-L465" target="_blank" title="https://github.com/rust-lang/rust/blob/9ebf47851a357faa4cd97f4b1dc7835f6376e639/src/libsyntax_ext/proc_macro_server.rs#L454-L465">https://github.com/rust-lang/rust/blob/9ebf47851a357faa4cd97f4b1dc7835f6376e639/src/libsyntax_ext/proc_macro_server.rs#L454-L465</a></p>



<a name="171292335"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/182449-t-compiler/help/topic/simplifying%20macro%20repros/near/171292335" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> lqd <a href="https://rust-lang.github.io/zulip_archive/stream/182449-t-compiler/help/topic/simplifying.20macro.20repros.html#171292335">(Jul 19 2019 at 20:49)</a>:</h4>
<p>interesting</p>



<a name="171292422"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/182449-t-compiler/help/topic/simplifying%20macro%20repros/near/171292422" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> davidtwco <a href="https://rust-lang.github.io/zulip_archive/stream/182449-t-compiler/help/topic/simplifying.20macro.20repros.html#171292422">(Jul 19 2019 at 20:50)</a>:</h4>
<p>Yeah, that is interesting.</p>



<a name="171292453"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/182449-t-compiler/help/topic/simplifying%20macro%20repros/near/171292453" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> davidtwco <a href="https://rust-lang.github.io/zulip_archive/stream/182449-t-compiler/help/topic/simplifying.20macro.20repros.html#171292453">(Jul 19 2019 at 20:51)</a>:</h4>
<p>Implies that dummy spans can be valid?</p>



<a name="171292530"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/182449-t-compiler/help/topic/simplifying%20macro%20repros/near/171292530" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> lqd <a href="https://rust-lang.github.io/zulip_archive/stream/182449-t-compiler/help/topic/simplifying.20macro.20repros.html#171292530">(Jul 19 2019 at 20:52)</a>:</h4>
<p>maybe ? at the very least known to happen in some cases let's say</p>



<a name="171292548"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/182449-t-compiler/help/topic/simplifying%20macro%20repros/near/171292548" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> davidtwco <a href="https://rust-lang.github.io/zulip_archive/stream/182449-t-compiler/help/topic/simplifying.20macro.20repros.html#171292548">(Jul 19 2019 at 20:52)</a>:</h4>
<p>Yeah, that’s reasonable.</p>



<a name="171292891"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/182449-t-compiler/help/topic/simplifying%20macro%20repros/near/171292891" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> lqd <a href="https://rust-lang.github.io/zulip_archive/stream/182449-t-compiler/help/topic/simplifying.20macro.20repros.html#171292891">(Jul 19 2019 at 20:58)</a>:</h4>
<p>how hard it is to actually turn DUMMY_SP into a proc_macro::Span is a testament to rustc's crates privacy design, good job :)</p>



<a name="171302840"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/182449-t-compiler/help/topic/simplifying%20macro%20repros/near/171302840" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Vadim Petrochenkov <a href="https://rust-lang.github.io/zulip_archive/stream/182449-t-compiler/help/topic/simplifying.20macro.20repros.html#171302840">(Jul 20 2019 at 00:19)</a>:</h4>
<p>I didn't look into the details, but DUMMY_SP in proc macro tokens means that the tokens were obtained through pretty-printing and then re-parsing the input.</p>



<a name="171302908"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/182449-t-compiler/help/topic/simplifying%20macro%20repros/near/171302908" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Vadim Petrochenkov <a href="https://rust-lang.github.io/zulip_archive/stream/182449-t-compiler/help/topic/simplifying.20macro.20repros.html#171302908">(Jul 20 2019 at 00:21)</a>:</h4>
<p>This happens as a fallback when the original tokens are unavailable or invalidated in any way (<a href="https://github.com/rust-lang/rust/issues/43081" target="_blank" title="https://github.com/rust-lang/rust/issues/43081">https://github.com/rust-lang/rust/issues/43081</a>).</p>



<a name="171303775"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/182449-t-compiler/help/topic/simplifying%20macro%20repros/near/171303775" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> lqd <a href="https://rust-lang.github.io/zulip_archive/stream/182449-t-compiler/help/topic/simplifying.20macro.20repros.html#171303775">(Jul 20 2019 at 00:46)</a>:</h4>
<p>it took a while but I figured it out <span class="user-mention" data-user-id="116107">@davidtwco</span></p>



<a name="171303796"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/182449-t-compiler/help/topic/simplifying%20macro%20repros/near/171303796" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> lqd <a href="https://rust-lang.github.io/zulip_archive/stream/182449-t-compiler/help/topic/simplifying.20macro.20repros.html#171303796">(Jul 20 2019 at 00:47)</a>:</h4>
<p>after trying a lot of things including setting up a rustc driver to force the dummy_sp, I saw the light of day</p>



<a name="171303844"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/182449-t-compiler/help/topic/simplifying%20macro%20repros/near/171303844" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> lqd <a href="https://rust-lang.github.io/zulip_archive/stream/182449-t-compiler/help/topic/simplifying.20macro.20repros.html#171303844">(Jul 20 2019 at 00:48)</a>:</h4>
<p>the dummy_sp was in the input along, <a href="https://github.com/davidtwco/rust-reproduction-issue-61963/pull/1" target="_blank" title="https://github.com/davidtwco/rust-reproduction-issue-61963/pull/1">PR here</a></p>



<a name="171303852"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/182449-t-compiler/help/topic/simplifying%20macro%20repros/near/171303852" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> lqd <a href="https://rust-lang.github.io/zulip_archive/stream/182449-t-compiler/help/topic/simplifying.20macro.20repros.html#171303852">(Jul 20 2019 at 00:49)</a>:</h4>
<p>depending on how you override the spans the error can be different</p>



<a name="171303917"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/182449-t-compiler/help/topic/simplifying%20macro%20repros/near/171303917" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> lqd <a href="https://rust-lang.github.io/zulip_archive/stream/182449-t-compiler/help/topic/simplifying.20macro.20repros.html#171303917">(Jul 20 2019 at 00:51)</a>:</h4>
<p>if you clobber them all it will have an error like </p>
<div class="codehilite"><pre><span></span>^ help: use `dyn`: `dyn #`
</pre></div>



<a name="171303937"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/182449-t-compiler/help/topic/simplifying%20macro%20repros/near/171303937" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> lqd <a href="https://rust-lang.github.io/zulip_archive/stream/182449-t-compiler/help/topic/simplifying.20macro.20repros.html#171303937">(Jul 20 2019 at 00:51)</a>:</h4>
<p>so I set it up like the original code did with <code>quote</code>and it matches the error you expect</p>
<div class="codehilite"><pre><span></span>help: use `dyn`: `dyn #[dom_struct]`
</pre></div>



<a name="171316358"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/182449-t-compiler/help/topic/simplifying%20macro%20repros/near/171316358" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> davidtwco <a href="https://rust-lang.github.io/zulip_archive/stream/182449-t-compiler/help/topic/simplifying.20macro.20repros.html#171316358">(Jul 20 2019 at 07:31)</a>:</h4>
<p>That’s awesome!</p>



<a name="171316399"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/182449-t-compiler/help/topic/simplifying%20macro%20repros/near/171316399" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> davidtwco <a href="https://rust-lang.github.io/zulip_archive/stream/182449-t-compiler/help/topic/simplifying.20macro.20repros.html#171316399">(Jul 20 2019 at 07:32)</a>:</h4>
<p>Thanks a bunch.</p>



<a name="171316515"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/182449-t-compiler/help/topic/simplifying%20macro%20repros/near/171316515" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> davidtwco <a href="https://rust-lang.github.io/zulip_archive/stream/182449-t-compiler/help/topic/simplifying.20macro.20repros.html#171316515">(Jul 20 2019 at 07:36)</a>:</h4>
<p>Does that still preserve the original warning too on the field?</p>



<a name="171316519"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/182449-t-compiler/help/topic/simplifying%20macro%20repros/near/171316519" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> davidtwco <a href="https://rust-lang.github.io/zulip_archive/stream/182449-t-compiler/help/topic/simplifying.20macro.20repros.html#171316519">(Jul 20 2019 at 07:36)</a>:</h4>
<p>(it doesn’t really matter but it’d be interesting)</p>



<a name="171319468"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/182449-t-compiler/help/topic/simplifying%20macro%20repros/near/171319468" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> davidtwco <a href="https://rust-lang.github.io/zulip_archive/stream/182449-t-compiler/help/topic/simplifying.20macro.20repros.html#171319468">(Jul 20 2019 at 09:11)</a>:</h4>
<p>I've pushed your changes to the repro repository and modified the attribute crate so that it is also token-for-token identical to what <code>quote</code>/<code>syn</code> was outputting.</p>



<a name="171320176"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/182449-t-compiler/help/topic/simplifying%20macro%20repros/near/171320176" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> lqd <a href="https://rust-lang.github.io/zulip_archive/stream/182449-t-compiler/help/topic/simplifying.20macro.20repros.html#171320176">(Jul 20 2019 at 09:34)</a>:</h4>
<p>it's probably not the most minimal repro of the spirit of the bug, as we're making sure the tokens match the original but it's likely small enough to be debugged, and have it as a regression test</p>



<a name="171320228"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/182449-t-compiler/help/topic/simplifying%20macro%20repros/near/171320228" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> davidtwco <a href="https://rust-lang.github.io/zulip_archive/stream/182449-t-compiler/help/topic/simplifying.20macro.20repros.html#171320228">(Jul 20 2019 at 09:34)</a>:</h4>
<p>Yeah, I think that's the best that we could hope for.</p>



<a name="171320283"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/182449-t-compiler/help/topic/simplifying%20macro%20repros/near/171320283" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> lqd <a href="https://rust-lang.github.io/zulip_archive/stream/182449-t-compiler/help/topic/simplifying.20macro.20repros.html#171320283">(Jul 20 2019 at 09:36)</a>:</h4>
<p>alright cheers David, enjoy the weekend :)</p>



<a name="171320285"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/182449-t-compiler/help/topic/simplifying%20macro%20repros/near/171320285" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> davidtwco <a href="https://rust-lang.github.io/zulip_archive/stream/182449-t-compiler/help/topic/simplifying.20macro.20repros.html#171320285">(Jul 20 2019 at 09:36)</a>:</h4>
<p>You too, thanks a ton for the help.</p>



<hr><p>Last updated: Aug 07 2021 at 22:04 UTC</p>
</html>